module jinji.link.model;

import jinji.common.model;
import jinji.config;

/// 链接
@snakeCase
@noRowid struct Link {
@notnull:
	/// URL
	@PK @sqltype(text("varchar(", maxURLLength, ")")) string url;
	/// 链接状态
	@check!("status", LinkStatus)
	LinkStatus status = LinkStatus.flagged;
	/// 链接类型
	@default0 LinkType type;
	/// 内容长度
	@default0 long size;
	mixin timeInfo;
	/// 256bit blake3
	@check!"length(hash)=32"@(.type("Uint8Array")) Hash hash;
}

/// 链接别名
@snakeCase
struct LinkAlias {
	/// 链接别名ID
	@serial Id id;
@notnull:
	/// 查找内容
	@unique string pattern;
	/// 替换内容
	string substitute;
	/// 描述
	@defEmpty @descT Desc desc;
	mixin timeInfo!true;
}

/// 链接别名可见性
@snakeCase
struct LAVisibility {
@notnull:
	/// 链接别名ID
	@PK @FK!(LinkAlias.id) Id id;
	mixin Visibility;
}
